import request from '@/utils/request'
// 获取spu列表数据
// 携带参数 page limit category3Id
// GET /admin/product/{ page}/{limit}
export const reqSpuList = (page, limit, category3Id) => request({
  method: 'GET',
  url: `/admin/product/${page}/${limit}`,
  params: {
    category3Id
  }
})
// 根据Id获取spu的商品信息
/* GET /admin/product/getSpuById/{spuId} */
export const reqSpu = (id) => request({
  url: `/admin/product/getSpuById/${id}`,
  method: 'GET'
})
// 品牌详细数据
// GET /admin/product/baseTrademark/getTrademarkList    GET /admin/product/baseTrademark/getTrademarkList
export const reqTrademarkList = () => request({
  url: `/admin/product/baseTrademark/getTrademarkList`,
  method: 'GET'
})
// 获取spu图片
// GET /admin/product/spuImageList/{spuId}
export const reqSpuImageLIST = (spuId) => request({
  url: `/admin/product/spuImageList/${spuId}`,
  method: 'GET'
})
// 获取品台全部销售属性
// GET / admin / product / baseSaleAttrList
export const reqBaseSaleAttrList = () => request({
  url: '/admin/product/baseSaleAttrList',
  method: 'GET'
})
// 修改spu
// POST / admin / product / updateSpuInfo
// 添加spu
// POST / admin / product / saveSpuInfo
// 修改与添加spu 修改与添加携带的参数基本一致 修改需要添加id
export const reqAddOrUpdataSpu = spuInfo => {
  if (spuInfo.id) {
    return request({
      url: '/admin/product/updateSpuInfo',
      method: 'POST',
      data: spuInfo
    })
  } else {
    return request({
      url: '/admin/product/saveSpuInfo',
      method: 'POST',
      data: spuInfo
    })
  }
}
// 删除spu商品信息
// DELETE /admin/product/deleteSpu/{spuId}
export const reqDeleteSpu = (spuId) => request({
  url: `/admin/product/deleteSpu/${spuId}`,
  method: 'DELETE'
})
// 获取spu图片数据
// GET /admin/product/spuImageList/{spuId}
export const reqSpuImageList = (spuId) => request({
  url: `/admin/product/spuImageList/${spuId}`,
  method: 'GET'
})
// 获取spu销售属性列表
// GET /admin/product/spuSaleAttrList/{spuId}
export const reqSpuSaleAttrList = (spuId) => request({
  method: 'GET',
  url: `/admin/product/spuSaleAttrList/${spuId}`
})
// GET /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
// 获取商品基础属性列表
export const reqAttrInfoList = (category1Id, category2Id, category3Id) => request({
  url: `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`,
  method: 'GET'
})
// 添加sku
// POST / admin / product / saveSkuInfo
export const reqAddSku = (skuInfo) => request({
  url: '/admin/product/saveSkuInfo',
  method: 'POST',
  data: skuInfo
})
// 通过spuid获取sku列表数据
// GET /admin/product/findBySpuId/{spuId}
export const reqSkuList = (spuId) => request({
  url: `/admin/product/findBySpuId/${spuId}`,
  method: 'GET'
})
